<!DOCTYPE html>
<html>
<head>
<meta charset="iso-8859-1">
<style>
body,td,th{font-family:sans-serif}
a.sort_link{margin-left:10px;text-decoration:none}
</style>

<script type="text/javascript" src="../src/brython_builtins.js"></script>
<script type="text/javascript" src="../src/version_info.js"></script>
<script type="text/javascript" src="../src/py2js.js"></script>
<script type="text/javascript" src="../src/loaders.js"></script>
<script type="text/javascript" src="../src/py_object.js"></script>
<script type="text/javascript" src="../src/py_type.js"></script>
<script type="text/javascript" src="../src/py_utils.js"></script>
<script type="text/javascript" src="../src/py_builtin_functions.js"></script>
<script type="text/javascript" src="../src/py_exceptions.js"></script>
<script type="text/javascript" src="../src/py_range_slice.js"></script>
<script type="text/javascript" src="../src/py_bytes.js"></script>
<script type="text/javascript" src="../src/py_set.js"></script>
<script type="text/javascript" src="../src/js_objects.js"></script>
<script type="text/javascript" src="../src/stdlib_paths.js"></script>
<script type="text/javascript" src="../src/py_import.js"></script>
<script type="text/javascript" src="../src/unicode_data.js"></script>
<script type="text/javascript" src="../src/py_string.js"></script>
<script type="text/javascript" src="../src/py_int.js"></script>
<script type="text/javascript" src="../src/py_long_int.js"></script>
<script type="text/javascript" src="../src/py_float.js"></script>
<script type="text/javascript" src="../src/py_complex.js"></script>
<script type="text/javascript" src="../src/py_dict.js"></script>
<script type="text/javascript" src="../src/py_list.js"></script>
<script type="text/javascript" src="../src/py_generator.js"></script>
<script type="text/javascript" src="../src/py_dom.js"></script>

<script type="text/javascript" src="../src/builtin_modules.js"></script>
<script type="text/javascript" src="../src/py_import_hooks.js"></script>

<script type="text/python" src="show_source.py"></script>
</head>
<body onLoad="brython(1)">

<div id="result">(empty)</div>
<button id="get_text">get text file</button>
<button id="i_dont_exist">file not found</button>
<button id="get_test">GET request</button>
<button id="post_test">POST request</button>

<script id="ascript" type="text/python">
import time

from browser import document, ajax, bind

def fake_qs():
    return "?foo=%s" %time.time()

def show(req):
    document["result"].html = req.text

@bind("#get_test", "click")
def get(ev):
    ajax.get("/cgi-bin/get_test.py",
             oncomplete=show,
             data={"foo": 34})

@bind("#post_test", "click")
def post(ev):
    ajax.post("/cgi-bin/post_test.py",
             oncomplete=show,
             data={"foo": 34})

@bind("#get_text", "click")
def get_text(ev):
    ajax.get("ajax_data.txt" + fake_qs(),
             timeout=7,
             oncomplete=show)

@bind("#i_dont_exist", "click")
def i_dont_exist(ev):
    ajax.get("i_dont_exist.txt" + fake_qs(),
             timeout=7,
             oncomplete=show)

</script>

</body>
</html>

